﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace OrganizeYourSearch
{
    public class Tag : INotifyPropertyChanged
    {
        private const int MaxFontSize = 30, MinFontSize = 8;

        public long TagId { get; set; }
        public string TagName { get; set; }
        public long CurrentFreq { get; set; }
        public int SizeFactor { get; set; }

        public Tag()
        {

        }
        public Tag(long v_tagId, long curFreq, string v_tagName, long maxFreq, long minFreq)
        {
            TagId = v_tagId;
            TagName = v_tagName;
            CurrentFreq = curFreq;
            SizeFactor = CalculateSizeFactor(curFreq, maxFreq, minFreq);
        }

        private int CalculateSizeFactor(long curFreq, long maxFreq, long minFreq)
        {
            double multiplyFactor = (MaxFontSize - MinFontSize) / (maxFreq - minFreq);
            int size = (int)(MinFontSize + (maxFreq - (maxFreq - (curFreq - minFreq))) * multiplyFactor);
            return size;
        }

        #region INotifyPropertyChanged Members
        // Property Changed Event
        public event PropertyChangedEventHandler PropertyChanged;
        // Function to explicitly raise the event
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, e);
            }
        }

        #endregion
    }
}
